package logic

import (
	"context"
	"mini/minirpc/minirpc"
	"mini/pkg"

	"mini/miniapi/internal/svc"
	"mini/miniapi/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ProjectLikeLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewProjectLikeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProjectLikeLogic {
	return &ProjectLikeLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ProjectLikeLogic) ProjectLike(req *types.ProjectLikeRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	like, err := l.svcCtx.MiniRpc.ProductLike(l.ctx, &minirpc.ProductLikeRequest{Id: int64(req.Id)})
	if err != nil {
		return &types.Response{
			Message: pkg.String(err.Error()),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "点赞成功",
		Code:    200,
		Data:    like,
	}, nil
}
